<?php

namespace Api\Http\Controllers;

use Api\traits\ApiResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redis;
use Modules\Cms\Models\Source;
use Modules\Member\Models\Members;

class SourcesController extends Controller
{
    use ApiResponse;

    public function __construct(
        protected readonly Source $model
    )
    {

    }

    public function list(Request $request)
    {
        $type = $request->get('type');
        $list = $this->model->where('type', $type)->orderByDesc('id')->paginate(10);
        return $this->data($list->toArray());
    }

    public function getNetdiskUrl()
    {
        $url = 'https://pan.baidu.com/s/1npihcbqT3mvQ5gtNA4jq_Q?pwd=9999';
        $data['url'] = $url;
        return $this->data($data);
    }



    public function getUserTeam($userId)
    {
        static $ids = [];
        $info = Members::where('pid',$userId)->pluck('id');



        foreach ($info as $v){
            $ids[] = $v;
            $this->getUserTeam($v);
        }



        return $ids;
    }
}
